<template>
  <div class="digital_report">
    <table-common
      :menu-id="menuId"
      :title="title"
      :form-guid="formGuid"
      :filter-list="filterList"
      @cellDblclick="cellDblclick"
    />
    <a-modal
      :title="modalTitle"
      :visible="dbclickVisible"
      width="88vw"
      class="dbclickModal"
      :body-style="{height:'60vh'}"
      cancel-text="取消"
      ok-text="确定"
      @ok="dbclickOk"
      @cancel="dbclickCancel"
    >
      <table-common
        :menu-id="dbclickMenuId"
        :filter-list="dbclickFilterList"
      />
    </a-modal>
  </div>
</template>

<script>
import tableCommon from '@/components/tableCommon/index.vue';

export default {
  name: 'DigitalReport',
  components: {
    tableCommon
  },
  data() {
    return {
      menuId: undefined,
      title: '',
      formGuid: '',
      dbclickVisible: false,
      dbclickMenuId: undefined,
      dbclickTitle: '',
      dbclickFilterList: [],
      modalTitle: '',
      xcRoleId: '',
      filterList: []
    };
  },
  mounted() {
    window.parent.postMessage(
      {
        title: this.$route.query.title,
        parentTitle: this.$route.query.parentName
      },
      '*'
    );
  },
  created() {
    const { menuId, title, formGuid, ENTERPRISECODE } = this.$route.query;
    this.xcRoleId = localStorage.getItem('xcRoleId');
    this.menuId = Number(menuId);
    this.title = title;
    this.formGuid = formGuid;
    if (title === '数据模型' && ENTERPRISECODE && this.xcRoleId !== '458') {
      this.filterList = [{ col: 'ENTERPRISECODE', value: ENTERPRISECODE }];
    }
  },
  methods: {
    cellDblclick(val) {
      if (['按指标类型查询表', '按上级补助查询', '按本级预算查询'].includes(this.title)) {
        const { CENTERPRISECODE, CFROMFILENO, CFROMSUMMARY, CPROGRAMNAME, CBUDGETCATEGORYNAME, CENTERPRISENAME } = val;
        this.dbclickVisible = true;
        this.dbclickMenuId = 1625560591476;
        this.modalTitle = this.title;
        this.dbclickFilterList = [{
          col: 'CENTERPRISECODE', value: CENTERPRISECODE
        }, {
          col: 'CFROMFILENO', value: CFROMFILENO
        }, {
          col: 'CFROMSUMMARY', value: CFROMSUMMARY
        }, {
          col: 'CPROGRAMNAME', value: CPROGRAMNAME
        }, {
          col: 'CBUDGETCATEGORYNAME', value: CBUDGETCATEGORYNAME
        }, {
          col: 'CENTERPRISENAME', value: CENTERPRISENAME
        }];
      }
    },
    dbclickCancel() {
      this.dbclickVisible = false;
    },
    dbclickOk() {
      this.dbclickVisible = false;
    }
  }
};
</script>
<style lang="scss" scoped>
.digital_report {
  height: 100%;
}
</style>
